<template>
	<view class="uni-common-pb uni-padding-wrap uni-common-mt">
		<view class="content">
			<text class="title0">{{detail.subtitle}}</text>
		</view>

		<view class="uni-form-item uni-row">
			<view class="title">工单编号</view>
			<view class="title">{{detail.workordernumber}}</view>
		</view>

		<view class="uni-form-item uni-row">
			<view class="title">产品品号</view>
			<view class="title">{{detail.productname}}</view>
		</view>

		<view class="uni-form-item uni-row">
			<view class="title">全长</view>
			<view class="title">{{detail.fulllength}}</view>
		</view>

		<view class="uni-form-item uni-row">
			<view class="title">规格名</view>
			<view class="title">{{detail.specname}}</view>
		</view>

		<view class="uni-form-item uni-row">
			<view class="title">发料记录</view>
			<view class="title">{{detail.issuerecord}}</view>
		</view>

		<view class="uni-form-item uni-row">
			<view class="title">备注</view>
			<view class="title">{{detail.info}}</view>
		</view>

		<view class="line-item"></view>

		<view class="uni-form-item uni-row">
			<view class="title">制程开始时间</view>
			<view class="title">{{detail.starttime}}</view>
		</view>

		<view class="uni-form-item uni-row">
			<view class="title">制程完成时间</view>
			<view class="title">{{detail.endtime}}</view>
		</view>

		<view class="uni-form-item uni-row">
			<view class="title">操作者</view>
			<view class="title">{{detail.processlog.step_operator}}</view>
		</view>

		<view class="uni-form-item uni-row">
			<view class="title">工时</view>
			<view class="title">{{detail.step_time}}&nbsp;&nbsp;小时</view>
		</view>

		<view class="uni-form-item uni-row">
			<view class="title">序号</view>
			<view class="title">{{detail.processlog.step_number}}</view>
		</view>
		<view class="uni-form-item uni-row">
			<view class="title">制程代号</view>
			<view class="title">{{detail.processlog.step_code}}</view>
		</view>
		<view class="uni-form-item uni-row">
			<view class="title">制程名称</view>
			<view class="title">{{detail.processlog.step_name}}</view>
		</view>
		<view class="uni-form-item uni-row">
			<view class="title">良品</view>
			<view class="title">{{detail.processlog.step_num_ok}}</view>
		</view>
		<view class="uni-form-item uni-row">
			<view class="title">不良</view>
			<view class="title">{{detail.processlog.step_num_ng}}</view>
		</view>

		<view class="uni-form-item uni-row">
			<view class="title">原料不良</view>
			<view class="title">{{detail.processlog.step_num_pm}}</view>
		</view>

		<view class="uni-form-item uni-row">
			<view class="title">报废断针</view>
			<view class="title">{{detail.processlog.step_num_scrap_a}}</view>
		</view>

		<view class="uni-form-item uni-row">
			<view class="title">报废其它</view>
			<view class="title">{{detail.processlog.step_num_scrap_b}}</view>
		</view>

		<view class="uni-form-item uni-row">
			<view class="title">报废原因</view>
			<view class="title2">{{detail.processlog.scrap_content}}</view>
		</view>
		<view class="uni-form-item uni-row">
			<view class="title">备注</view>
			<view class="title2">{{detail.processlog.content}}</view>
		</view>

		<view v-if="detail.processlog.step_code==='S1'||detail.processlog.step_code==='S1-5'||detail.processlog.step_code==='S2' ">
			<view class="uni-form-item uni-row">
				<view class="title">清洗时间（小时）</view>
				<view class="title2">{{detail.processlog.qingxitime}}</view>

			</view>

			<view class="uni-form-item uni-row">
				<view class="title">烘干时间（小时）</view>
				<view class="title2">{{detail.processlog.honggantime}}</view>

			</view>
		</view>
		<view class="line-item"></view>

		<view v-if="detail.processlog.step_code==='M' ">
			<view class="title">精磨检查</view>
			<view class="uni-form-item uni-row">
				<view class="title">直大数</view>
				<view class="title2">{{detail.processlog.m_num_ng1}}</view>
			</view>
			<view class="uni-form-item uni-row">
				<view class="title">直小数</view>
				<view class="title2">{{detail.processlog.m_num_ng2}}</view>
			</view>

			<view class="uni-form-item uni-row">
				<view class="title">锥大数</view>
				<view class="title2">{{detail.processlog.m_num_ng3}}</view>
			</view>

			<view class="uni-form-item uni-row">
				<view class="title">锥小数</view>
				<view class="title2">{{detail.processlog.m_num_ng4}}</view>
			</view>

			<view class="uni-form-item uni-row">
				<view class="title">真圆数</view>
				<view class="title2">{{detail.processlog.m_num_ng5}}</view>
			</view>
			<view class="uni-form-item uni-row">
				<view class="title">柄大/小数</view>
				<view class="title2">{{detail.processlog.m_num_ng6}}</view>
			</view>
			<view class="uni-form-item uni-row">
				<view class="title">刮伤数</view>
				<view class="title2">{{detail.processlog.m_num_ng7}}</view>
			</view>
			<view class="uni-form-item uni-row">
				<view class="title">原料不良数</view>
				<view class="title2">{{detail.processlog.m_num_ng8}}</view>
			</view>
			<view class="uni-form-item uni-row">
				<view class="title">偏摆数</view>
				<view class="title2">{{detail.processlog.m_num_ng9}}</view>
			</view>
			<view class="uni-form-item uni-row">
				<view class="title">其他数</view>
				<view class="title2">{{detail.processlog.m_num_ng10}}</view>
			</view>
		</view>

		<view v-if="detail.processlog.step_code==='SJ-5' ">
			<view class="title">生五焊接</view>
			<view class="uni-form-item uni-row">
				<view class="title">歪头数</view>
				<view class="title2">{{detail.processlog.sj5_num_ng1}}</view>
			</view>
			<view class="uni-form-item uni-row">
				<view class="title">焊接颠数</view>
				<view class="title2">{{detail.processlog.sj5_num_ng2}}</view>
			</view>

			<view class="uni-form-item uni-row">
				<view class="title">焊缝不良数</view>
				<view class="title2">{{detail.processlog.sj5_num_ng3}}</view>
			</view>
			<view class="uni-form-item uni-row">
				<view class="title">全长不良数</view>
				<view class="title2">{{detail.processlog.sj5_num_ng4}}</view>
			</view>
			<view class="uni-form-item uni-row">
				<view class="title">外观不良数</view>
				<view class="title2">{{detail.processlog.sj5_num_ng5}}</view>
			</view>
			<view class="uni-form-item uni-row">
				<view class="title">断针数</view>
				<view class="title2">{{detail.processlog.sj5_num_ng6}}</view>
			</view>
			<view class="uni-form-item uni-row">
				<view class="title">混料数</view>
				<view class="title2">{{detail.processlog.sj5_num_ng7}}</view>
			</view>
			<view class="uni-form-item uni-row">
				<view class="title">原料不良数</view>
				<view class="title2">{{detail.processlog.sj5_num_ng8}}</view>
			</view>
			<view class="uni-form-item uni-row">
				<view class="title">偏摆数</view>
				<view class="title2">{{detail.processlog.sj5_num_ng9}}</view>
			</view>
			<view class="uni-form-item uni-row">
				<view class="title">其他数</view>
				<view class="title2">{{detail.processlog.sj5_num_ng10}}</view>
			</view>
			<view class="uni-form-item uni-row">
				<view class="title">焊片厂家数</view>
				<view class="title2">{{detail.processlog.sj5_num_ng11}}</view>
			</view>
		</view>

		<view class="line-item"></view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				detail: [],
			};
		},
		onLoad(e) {
			// 目前在某些平台参数会被主动 decode，暂时这样处理。
			console.log(e.detail);
			try {
				this.detail = JSON.parse(decodeURIComponent(event.detail));
			} catch (error) {
				this.detail = JSON.parse(e.detail);
			}

			this.detail.starttime = this.formatUnixtimestamp(this.detail.processlog.starttime);
			this.detail.endtime = this.formatUnixtimestamp(this.detail.processlog.endtime);
			this.detail.step_time = '--';
			if (this.detail.processlog.endtime > 0) {
				this.detail.step_time = Math.round((this.detail.processlog.endtime - this.detail.processlog.starttime) / 3600);
			}
		},
		methods: {
			formatUnixtimestamp: function(e) {
				if (e == 0) {
					return '--';
				}

				var unixtimestamp = new Date(e * 1000);
				var year = 1900 + unixtimestamp.getYear();
				var month = "0" + (unixtimestamp.getMonth() + 1);
				var date = "0" + unixtimestamp.getDate();
				var hour = "0" + unixtimestamp.getHours();
				var minute = "0" + unixtimestamp.getMinutes();
				var second = "0" + unixtimestamp.getSeconds();
				return year + "-" + month.substring(month.length - 2, month.length) + "-" + date.substring(date.length - 2, date.length) +
					" " + hour.substring(hour.length - 2, hour.length) + ":" +
					minute.substring(minute.length - 2, minute.length) + ":" +
					second.substring(second.length - 2, second.length);
			}
		}
	}
</script>

<style>
	.line-item {
		height: 1upx;
		background: #999999;
		color: #FFF;
	}

	.title {
		font-size: 30upx;
		width: 265upx;
	}

	.text-box {
		min-height: 200upx;
		width: 100%;
		background-color: #FFFFFF;
		justify-content: left;
		align-items: left;
		text-align: left;
		font-size: 30upx;
		color: #353535;
		line-height: 1.8;
	}

	.title2 {
		font-size: 30upx;
		width: 265upx;
		height: 200upx;
	}
</style>
